import types from "../types/types"

// 定义user模块的数据
const userState = {
    userinfo: {
        username: "朱总理",
        age: 88
    }
}

// 定义操作user模块的reducer 
function userReducer(state = userState, action) {
    if (action.type == types.user.addAge) {
        return {
            userinfo: {
                //  username: "朱总理",
                //  age: 88
                ...state.userinfo,
                age: state.userinfo.age + action.payload
            }
        }

    }

    return state  // 否则返回原state
}


export default userReducer